var express = require('express');
var router = express.Router();
var db = require('../public/javascripts/db');

router.post('/', (req, res) => {
    console.log(req.body);
    var sql = "SELECT * FROM images WHERE id = ?";
    db.query(sql, req.body.imageId, (err, result) => {
        if (err) {
            throw err;
            return;
        } else {
            var sql1 = 'UPDATE images SET new_medical_num = ? WHERE id = ?';
            var sql1Params = [req.body.medicalNum, req.body.imageId];
            db.query(sql1, sql1Params, (err1, result1) => {
                if (err1) {
                    throw err1;
                    return;
                } else {
                    res.send({data:'update success'})
                }
            })
        }
    })
})

module.exports = router;
